﻿ <%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<string>" %>

<asp:Content runat="server" ContentPlaceHolderID="HeadContent">

    <link href="<%= Url.Content("~/WebCallr/webcallr.css") %>" rel="stylesheet" type="text/css" />
    <script src="<%= Url.Content("~/Scripts/jquery-1.4.1.js") %>" type="text/javascript"></script>
    <script src="<%= Url.Content("~/Scripts/jquery-ui-1.8.2.custom.min.js") %>" type="text/javascript"></script>
    <script src="<%= Url.Content("~/Scripts/jquery.cookie.js") %>" type="text/javascript"></script>
    <script src="<%= Url.Content("~/WebCallr/wfbot.js") %>" type="text/javascript"></script>
    <script src="<%= Url.Content("~/WebCallr/wfbotvideo.js") %>" type="text/javascript"></script>

    <script type="text/javascript">

        $(document).ready(function () {

            $('#call-btn').click(function () {
                if ($(this).hasClass('busy')) return;

                wfbot.init({ channel: '<%= ViewData.Model %>', endPoint: 'bot' });
            });

            setInterval(updateAvailability, 5000);

        });

        function initVideo() {
            wfbotvideo.call();

            wfbot.getAvailability(function (result) {
                if (result) {
                    $('#call-btn').removeClass('busy');
                }
                else {
                    $('#call-btn').addClass('busy');
                }
            });
        }

        function updateAvailability() {
            wfbot.getAvailability(function (result) {
                if (result) {
                    $('#call-btn').removeClass('busy');
                }
                else {
                    $('#call-btn').addClass('busy');
                }
            });
        }

    </script>

</asp:Content>

<asp:Content runat="server" ContentPlaceHolderID="MainContent">

    <div style="display: none;">
        <input type="button" value="text chat" onclick="initChat()" />
        <input type="button" value="start video" onclick="initVideo()" />
    </div>

    <div id="call-btn" class="busy"></div>
</asp:Content>